package com.lry.serialize;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lry.spi.LoadLevel;

@LoadLevel(name = "fastJson")
public class FastJsonSerializer implements Serializer {

    @Override
    public <T> byte[] serialize(T t) {
        String jsonStr = JSON.toJSONString(t);
        return jsonStr.getBytes();
    }

    @Override
    public <T> T deserialize(byte[] data) {
        return (T) JSONObject.parse(data);
    }

}
